from odoo import api, fields, models


class PROTECT(models.Model):
    _name = 'vaccine.protect'
    _description = 'vaccine_protect'

    name = fields.Char(
        default='药品不良反应/事件报告详情'
    )
    number_no = fields.Char(
        '报告编号',
        readonly=True,
        default='自动生成'
    )

    @api.model
    def create(self, vals):
        """
        自动生成单号
        :return:
        """
        vals['number_no'] = self.env['ir.sequence'].next_by_code('vaccine.protect') or ''
        return super(PROTECT, self).create(vals)

    vaccine_fun = fields.Selection(
        [
            ('001', '首次报告'),
            ('002', '跟踪报告')
        ],
        '报告种类'
    )
    vaccine_name = fields.Selection(
        [
            ('001', '新的'),
            ('002', '严重'),
            ('002', '一般')
        ],
        '报告类型',
    )
    vaccine_company = fields.Selection(
        [
            ('001', '医疗机构'),
            ('002', '经营企业'),
            ('003', '生产企业'),
            ('004', '个人')
        ],
        '报告单位类别',
    )
    vaccine_info = fields.Many2many(
        'user.info',
        string=r'患者信息',
    )
    vaccine_medical = fields.Many2many(
        'vaccine.information.entering',
        string='药品信息',
    )
    vaccine_phone = fields.Many2many(
        'bad.feel',
        string='不良反应记录',
    )
    vaccine_inoculate = fields.Selection(
        [
            ('001', '肯定'),
            ('002', '很可能'),
            ('003', '可能'),
            ('004', '可能无关'),
            ('005', '待评价'),
            ('006', '无法评价')
        ],
        '报告人评价',
        default='001',
    )
    vaccine_say = fields.Selection(
        [
            ('001', '肯定'),
            ('002', '很可能'),
            ('003', '可能'),
            ('004', '可能无关'),
            ('005', '待评价'),
            ('006', '无法评价')
        ],
        '报告单位评价',
        default='001',
    )
    protect_phone = fields.Char(
        '联系电话',
    )
    profession = fields.Selection(
        [
            ('001', '医生'),
            ('002', '药师'),
            ('003', '护士'),
            ('004', '其他')
        ],
        '职业',
        default='001',
    )
    email = fields.Char(
        '电子邮箱',
    )
